import * as js2color from "@/plugins/js2color";

function ChartOption() {
  this.color = ['#75C1FF', '#41A9FE', '#1A90FF', '#0D6ED9', '#024EB3', '#024297', '#01237E', '#011C65', '#01154C', '#010E32']
  this.tooltip = {
    trigger: "axis",
    axisPointer: {
      // 坐标轴指示器，坐标轴触发有效
      type: "shadow" // 默认为直线，可选为：'line' | 'shadow'
    },
    backgroundColor: "rgba(255,255,255,0.95)",
    padding: [12, 16],
    textStyle: {
      color: "rbga(0,0,0,0.65)"
    },
    formatter: function (params, ticket, callback) {
      // console.log(params, ticket, callback());
      let _str = ''
      params.forEach((item) => {
        if (item.data) {
          _str = _str + `${item.marker} ${item.seriesName}: ${item.data} <br />`
        }
      })
      return `${params[0].name} <br> ${_str.length > 0 ? _str : '无数据' }`
    }
  }
  this.legend = {
    data: []
  }
  this.grid = {
      left: "3%",
      right: "4%",
      bottom: "3%",
      containLabel: true
    },
    this.xAxis = {
      type: "value"
    },
    this.yAxis = {
      type: "category",
      data: [],
      offset: 12,
      triggerEvent: true
    },
    this.series = []
}

function SeriesOption() {
  this.name = "",
    this.type = "bar",
    this.stack = "总量",
    this.label = {
      normal: {
        show: true,
        position: "insideRight"
      }
    },
    this.barWidth = '50%'
    this.data = []
}

ChartOption.prototype.js2color = js2color

export {
  ChartOption,
  SeriesOption
}
